<?php
namespace app\restaurant\model;

use app\BaseModel;
use app\member\model\Member;
use longbingcore\wxcore\DadaApi;
use think\facade\Db;

class TransporterOrder extends BaseModel
{
    //定义表名
    protected $name = 'longbing_card_restaurant_transporter_order';


    /**
     * @author chenniang
     * @DataTime: 2020-10-30 10:55
     * @功能说明:添加订单
     */
    public function addOrder($data){

//        $data['create_time'] = time();

        $res = $this->insert($data);

        return $res;

    }


    /**
     * @author chenniang
     * @DataTime: 2020-10-30 11:19
     * @功能说明:订单详情
     */

    public function orderInfo($dis,$field='*'){

        $data = $this->where($dis)->field($field)->find();

        return !empty($data)?$data->toArray():[];


    }


    /**
     * @author chenniang
     * @DataTime: 2020-11-03 10:32
     * @功能说明:初始化
     */
    public function initOrder($order){

        $store_config_model = new StoreConfig();

        $store_config = $store_config_model->configInfo(['uniacid'=>$order['uniacid'],'store_id'=>$order['store_id']]);

        $insert = [

            'uniacid'    => $order['uniacid'],

            'order_id'   => $order['id'],

            'order_code' => $order['order_code'],

            'status'     => 0,

            'type'       => $store_config['send_type'],

            'order_type' => $order['order_type']
        ];

        $res = $this->addOrder($insert);

        return $res;

    }



}